<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('teachingSubstitute')} > ${i18n.getMessage('add')}">
	<a href="#" onclick="cc('offering/showListTeachingInterruption.sgt?offeringId=${(offering.id)!}')">${i18n.getMessage('list')}</a>
	- <a href="#" onclick="cc('offering/showInfoOffering.sgt?id=${(offering.id)!}')">${i18n.getMessage('offering')}</a>
</@showTitle>

<div id="error" style="display:none"></div>

<form action="offering/addTeachingInterruption.sgt" validator="offering/validateTeachingInterruption.sgt" onsubmit="submitFormValidation(this); return false;" onreset="$('error').hide()">
	<input type="hidden" name="offeringId" value="${offering.id}"/>
	
	<table id="dataTable" align="center" cellspacing="5" cellpadding="0">
		<tr>
			<td class="name"><@required/>${i18n.getMessage('class')}:</td>
			<td><input type="text" value="${(offering.name)!}" disabled style="width:200px"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('teacher')}:</td>
			<td>
				<select name="teacherId" style="width:204px">
					<option></option>
					<OPTGROUP LABEL="${i18n.getMessage('mainTeachers')}">
						<#list mainTeachers as t>
							<option value="${t.id}">${(t.fullName)!}</option>
						</#list>
					</OPTGROUP>
					<#if (subTeachers.size() > 0)>
					<OPTGROUP LABEL="${i18n.getMessage('otherTeachers')}">
						<#list subTeachers as t>	
							<option value="${t.id}">${(t.fullName)!}</option>
						</#list>
					</OPTGROUP>
					</#if>
					<#if (mainTAs.size() > 0)>
					<OPTGROUP LABEL="${i18n.getMessage('mainTAs')}">
						<#list mainTAs as t>	
							<option value="${t.id}">${(t.fullName)!}</option>
						</#list>
					</OPTGROUP>
					</#if>
					<#if (subTAs.size() > 0)>
					<OPTGROUP LABEL="${i18n.getMessage('otherTAs')}">
						<#list subTAs as t>	
							<option value="${t.id}">${(t.fullName)!}</option>
						</#list>
					</OPTGROUP>
					</#if>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('fromDate')}:</td>
			<td><input type="text" name="fromDate" value="${(fromDate)!now?date}" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].fromDate, '${i18n.getMessage('format.date')}', this)"/></td>
		</tr>
		<tr>
			<td class="name"><@required/>${i18n.getMessage('toDate')}:</td>
			<td><input type="text" name="toDate" value="${(fromDate)!now?date}" style="width:200px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].toDate, '${i18n.getMessage('format.date')}', this)"/> <a style="font-style:italic" href="#" onclick="document.forms[0].toDate.value='${(offering.endDate?date)!}'">Insert end date</a></td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('reason')}:</td>
			<td>
				<input type="radio" name="reason" value="SUBSTITUTE" checked onchange="$('substituteTeacherId').disabled=false;$('makeupFromDate').disabled=true;$('makeupToDate').disabled=true;$('staff').disabled=true"/> ${i18n.getMessage('substitute')}
				<input type="radio" name="reason" value="CANCEL" onchange="$('substituteTeacherId').disabled=true;$('makeupFromDate').disabled=false;$('makeupToDate').disabled=false;$('staff').disabled=true"/> ${i18n.getMessage('cancel')}
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('substituteTeacher')}:</td>
			<td>
				<select id="substituteTeacherId" name="substituteTeacherId" style="width:204px">
					<option></option>
					<OPTGROUP LABEL="${i18n.getMessage('teacher')}">
					<#list teachers as teacher>	
						<option value="${teacher.id}">${(teacher.lastName)!} ${(teacher.firstName)!}</option>
					</#list>
					</OPTGROUP>
					<OPTGROUP LABEL="${i18n.getMessage('ta')}">
					<#list tas as teacher>	
						<option value="${teacher.id}">${(teacher.lastName)!} ${(teacher.firstName)!}</option>
					</#list>
					</OPTGROUP>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('makeupDate')}:</td>
			<td>
				<input type="text" id="makeupFromDate" name="makeupFromDate" disabled style="width:76px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].makeupFromDate, '${i18n.getMessage('format.date')}', this)"/>
				<input type="text" id="makeupToDate" name="makeupToDate" disabled style="width:76px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].makeupToDate, '${i18n.getMessage('format.date')}', this)"/>
				(From - To)
			</td>
		</tr>
		<tr>
			<td class="name">${i18n.getMessage('staff')}:</td>
			<td>
				<select id="staff" name="staffId" style="width:204px" disabled>
					<option></option>
					<#list staffs as staff>	
						<option value="${staff.id}">${(staff.fullName)!}</option>
					</#list>
				</select>
			</td>
		</tr>
		<tr>
			<td class="name" style="vertical-align:top">${i18n.getMessage('comment')}:</td>
			<td><textarea name="comment" style="width:300px;height:80px"></textarea></td>
		</tr>
		<tr>
			<td></td>
			<td>
				<input type="submit" value="${i18n.getMessage('add')}" class="button_style"/> 
				<input type="reset" value="${i18n.getMessage('reset')}" class="button_style"/> 
			</td>
		</tr>
	</table>
</form>

<script>
	$('error').hide();
</script>